-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MINIFICPP-2159 Add heterogeneous lookup to FlatMap #1612
Conversation
libminifi/include/utils/FlatMap.h
Outdated
template<typename T> | ||
requires std::equality_comparable_with<K, T> | ||
bool contains(const T& key) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template<typename T> | |
requires std::equality_comparable_with<K, T> | |
bool contains(const T& key) const { | |
bool contains(std::equality_comparable_with<K> auto const& key) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, changed it and the others (except for operator[]) in f209288
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like MSVC doesnt like constraint auto, Im getting
C:\nifi-minifi-cpp\libminifi\test\unit\FlatMapTests.cpp(51): fatal error C1001: Internal compiler error.
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\trees.c', line 24533)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com/
I've found some reported issues with constraint auto and MSVC but those issues should be solved, ours is a bit more complex. I will try to create an MRE about this issue and file a bug with microsoft, in the meantime should I revert to explicit templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use the shortest for that's working with all targeted compilers.
That translates to first fallback to this:
template<std::equality_comparable_with<K> T>
bool contains(T const& key) const {
and second fallback to the original version.
On an unrelated note, we should add noexcept
wherever it makes sense. It may make our life easier down the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, the first fallback works on MSVC aswell. 617fc38
Adding noexcept where applicable is a good idea, I didnt find any obvious target on a quick glance, and I didnt want to burden this PR with a more complex analysis. Should I file a new jira for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For noexcept
, I was thinking operator[]
, find
, erase
and contains
. It may need to be conditional, e.g. erase
does swap
, so it needs to be std::is_nothrow_swappable_v
. I was hoping for noexcept
find
, but it would have to rely on a complex condition, so it may not be feasible after all.
If nothing obvious stands out, don't bother with the new Jira.
617fc38
to
25306bf
Compare
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically main)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.